<?php
/**
 * GioCMS
 * 
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2 
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@ninhgio.com so we can send you a copy immediately.
 * 
 * @copyright	Copyright (c) 2010-2011 GioCMS (http://cms.ninhgio.com)
 * @license		http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @author		NinhGio - ninhgio@gmail.com
 * @since		1.0
 */

class Gio_Core_Exception extends Exception
{
	/**
	 * @var array
	 */
	static $_CODE = array(
				0 => 'DATA_NOT_FOUND',
				1 => 'CLASS_NOT_FOUND',
				2 => 'METHOD_NOT_FOUND',
				3 => 'FILE_NOT_FOUND',
				4 => 'DIRECTORY_NOT_FOUND',
				5 => 'SERVER_OVERLOADING',
			);
		
	public static function exception(Exception $e)
	{
		$code = $e->getCode();
		$message = $e->getMessage();
		switch (self::$_CODE[$code]) {
			case 'DATA_NOT_FOUND':
				self::_dataNotFound($message);
				break;
			case 'CLASS_NOT_FOUND':
				self::_classNotFound($message);
				break;
			case 'METHOD_NOT_FOUND':
				self::_methodNotFound($message);
				break;
			case 'FILE_NOT_FOUND':
				self::_fileNotFound($message);
				break;
			case 'DIRECTORY_NOT_FOUND':
				self::_directoryNotFound($message);
				break;
			case 'SERVER_OVERLOADING':
				self::_serverOverloading($message);
				break;
			default:
				self::_dataNotFound($message);
				break;
			exit();
		}
	}
	
	private static function _dataNotFound($message = null)
	{
		echo $message;
	}
	
	private static function _classNotFound($message = null)
	{
		echo $message;
	}
	
	private static function _methodNotFound($message = null)
	{
		echo $message;
	}
	
	private static function _fileNotFound($message = null)
	{
		echo $message;
	}
	
	private static function _directoryNotFound($message = null)
	{
		echo $message;
	}
	
	private static function _serverOverloading($message = null)
	{
		echo $message;
	}
}